package com.netease.nie.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.base.utils.CopyUtils;
import com.netease.nie.common.CommonService;
import com.netease.nie.dao.RobGoodsInfoDao;
import com.netease.nie.dto.RobGoodsConfigDto;
import com.netease.nie.dto.RobGoodsInfoDto;
import com.netease.nie.model.RobGoodsInfo;

@Service
public class RobGoodsInfoServiceImpl extends CommonService implements RobGoodsInfoService {

	@Autowired
	private RobGoodsInfoDao robGoodsDao;

	public List<RobGoodsInfoDto> queryTopRobGoodsInfoDtos() {
		List<RobGoodsInfo> robGoodsInfoList = robGoodsDao.queryTopRobGoodsInfos();
		List<RobGoodsInfoDto> robGoodsInfoDtoList = generateRobGoodsInfoDtoList(robGoodsInfoList);
		return robGoodsInfoDtoList;
	}

	public List<RobGoodsInfoDto> queryMoreRobGoodsInfoDtos() {
		List<RobGoodsInfo> robGoodsInfoList = robGoodsDao.queryMoreRobGoodsInfos();
		List<RobGoodsInfoDto> robGoodsInfoDtoList = generateRobGoodsInfoDtoList(robGoodsInfoList);
		return robGoodsInfoDtoList;
	}

	public RobGoodsInfoDto queryRobGoodsInfoDtoByRobGoodsId(int robGoodsId) {
		RobGoodsInfo robGoodsInfo = robGoodsDao.queryRobGoodsInfoByRobGoodsId(robGoodsId);
		RobGoodsInfoDto robGoodsInfoDto = generateRobGoodsInfoDto(robGoodsInfo);
		return robGoodsInfoDto;
	}

	public Map<Integer, RobGoodsInfoDto> queryRobGoodsInfoDtoMapByRobGoodsIds(
			List<Integer> robGoodsIds) {
		List<RobGoodsInfo> robGoodsInfoList = robGoodsDao.queryRobGoodsInfosByRobGoodsIds(robGoodsIds);
		Map<Integer, RobGoodsInfoDto> robGoodsInfoDtoMap = generateRobGoodsInfoDtoMap(robGoodsInfoList);
		return robGoodsInfoDtoMap;
	}

	public RobGoodsConfigDto queryRobGoodsConfigDtoByRobGoodsId(int robGoodsId) {
		RobGoodsInfo robGoodsConfig = robGoodsDao.queryRobGoodsConfigByRobGoodsId(robGoodsId);
		if (robGoodsConfig != null) {
			RobGoodsConfigDto robGoodsConfigDto = new RobGoodsConfigDto();
			CopyUtils.copy(robGoodsConfigDto, robGoodsConfig);
			return robGoodsConfigDto;
		}
		return null;
	}

	public List<RobGoodsInfoDto> queryRobGoodsInfoDtosByRobGoodsIds(
			List<Integer> robGoodsIds) {
		List<RobGoodsInfo> robGoodsInfoList = robGoodsDao.queryRobGoodsInfosByRobGoodsIds(robGoodsIds);
		List<RobGoodsInfoDto> robGoodsInfoDtoList = generateRobGoodsInfoDtoList(robGoodsInfoList);
		return robGoodsInfoDtoList;
	}
}